package com.gpframework.module.process.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gpframework.common.utils.DateUtils;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.req.BaseReq;
import com.gpframework.module.process.domain.GpProcessIncomingInspect;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @ClassName GpProcessIncomingInspectReq
 * @Author gpframework
 * @Date 2023-12-20
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class GpProcessIncomingInspectReq extends BaseReq {
    private static final long serialVersionUID = 1L;

         @ApiModelProperty("${column.columnComment}")
     private Long id;
     @ApiModelProperty("品牌id")
     private String brandId;
     @ApiModelProperty("品牌名称")
     private String brandName;
     @ApiModelProperty("缺货报库存申请表id")
     private Long productionApplicationId;
     @ApiModelProperty("排单表id")
     private Long processSchedulingId;
     @ApiModelProperty("到货单id")
     private Long processDeliveryNoteId;
     @ApiModelProperty("订单号")
     private String sn;
     @ApiModelProperty("来料时间")
     private Date incomingTime;
    @ApiModelProperty("来料开始时间")
    private Date incomingStartTime;
    @ApiModelProperty("来料结束时间")
    private Date incomingEndTime;
     @ApiModelProperty("加工商ID")
     private Long processorId;
     @ApiModelProperty("加工商")
     private String processor;
     @ApiModelProperty("批号")
     private String batchNo;
     @ApiModelProperty("成品品名")
     private String productName;
     @ApiModelProperty("成品颜色")
     private String productColor;
     @ApiModelProperty("条数")
     private String numberItems;
     @ApiModelProperty("总码数（空）")
     private Integer totalSizeEmpty;
     @ApiModelProperty("总码数（足）")
     private Integer totalSizeSufficient;
     @ApiModelProperty("标准码（空)")
     private Integer standardCodeEmpty;
     @ApiModelProperty("标准码（足）")
     private Integer standardCodeSufficient;
     @ApiModelProperty("抽查数量（条）")
     private Integer samplingQuantity;
     @ApiModelProperty("差异值")
     private BigDecimal differenceValue;
     @ApiModelProperty("重量kg")
     private BigDecimal weight;
     @ApiModelProperty("测量整体幅宽")
     private BigDecimal measureOverallWidth;
     @ApiModelProperty("实用幅宽")
     private BigDecimal practicalWidth;
     @ApiModelProperty("标准幅宽")
     private BigDecimal standardWidth;
     @ApiModelProperty("植绒点点大小尺寸")
     private String flockingDotSize;
     @ApiModelProperty("植绒毛颜色对比")
     private String flockedFurColorComparison;
     @ApiModelProperty("片颜色对比")
     private String colorComparison;
     @ApiModelProperty("公斤数")
     private String kilograms;
     @ApiModelProperty("普通水洗")
     private String ordinaryWaterWashing;
     @ApiModelProperty("强洗1次")
     private String strongWashingOne;
     @ApiModelProperty("强洗2次")
     private String strongWashingTwo;
     @ApiModelProperty("干擦评定")
     private String dryWipeEvaluation;
     @ApiModelProperty("湿擦评定")
     private String wetWipeEvaluation;
    @ApiModelProperty("是否跟踪： 0否 1是")
    private String trackFlag;
     @ApiModelProperty("跟单员id")
     private Long documentaryId;
     @ApiModelProperty("跟单员")
     private String documentaryMan;
     @ApiModelProperty("操作人id")
     private Long operatorId;
     @ApiModelProperty("操作人")
     private String operatorName;
     @ApiModelProperty("操作时间")
     private Date operatorTime;
     @ApiModelProperty("排序")
     private Integer sort;
     @ApiModelProperty("备注")
     private String remarks;
     @ApiModelProperty("创建者")
     private String createBy;
     @ApiModelProperty("创建时间")
     private Date createTime;
     @ApiModelProperty("更新者")
     private String updateBy;
     @ApiModelProperty("更新时间")
     private Date updateTime;
     @ApiModelProperty("删除标记;0未删除。1已删除。")
     private Integer delStatus;
    @ApiModelProperty("查询条件（订单号/客户名）")
    private String searchName;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date searchDate;

    /** 操作人编号 */
    private String operatorNum;

    /**
    * @Description 生成查询wrapper
    * @Author greatplan@qq.com
    * @Date 2020-11-04 16:04
    * @Param [lqw]
    * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
    * @Return void
    */
    public void generatorQuery(QueryWrapper<GpProcessIncomingInspect> lqw,boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias+"del_status",0);

            lqw.orderByDesc(alias+"create_time");
        }
        if (this.getId() != null){
        lqw.eq(alias+"id" ,this.getId());
        }
        if (StringUtils.isNotBlank(this.getBrandId())){
        lqw.eq(alias+"brand_id" ,this.getBrandId());
        }
        if (StringUtils.isNotBlank(this.getBrandName())){
            lqw.like(alias+"brand_name",this.getBrandName());
        }
        if (this.getProductionApplicationId() != null){
        lqw.eq(alias+"production_application_id" ,this.getProductionApplicationId());
        }
        if (this.getProcessSchedulingId() != null){
        lqw.eq(alias+"process_scheduling_id" ,this.getProcessSchedulingId());
        }
        if (this.getProcessDeliveryNoteId() != null){
        lqw.eq(alias+"process_delivery_note_id" ,this.getProcessDeliveryNoteId());
        }
        if (StringUtils.isNotBlank(this.getSn())){
        lqw.like(alias+"sn" ,this.getSn());
        }
        if (this.getIncomingStartTime() != null){
            lqw.apply("DATE_FORMAT(gp.incoming_time, '%Y-%m-%d') >= '" + DateUtils.dateTime(this.getIncomingStartTime()) + "'");
        }
        if (this.getIncomingEndTime() != null){
            lqw.apply("DATE_FORMAT(gp.incoming_time, '%Y-%m-%d') <= '" + DateUtils.dateTime(this.getIncomingEndTime()) + "'");
        }
        if (this.getProcessorId() != null){
        lqw.eq(alias+"processor_id" ,this.getProcessorId());
        }
        if (StringUtils.isNotBlank(this.getProcessor())){
        lqw.like(alias+"processor" ,this.getProcessor());
        }
        if (StringUtils.isNotBlank(this.getBatchNo())){
        lqw.like(alias+"batch_no" ,this.getBatchNo());
        }
        if (StringUtils.isNotBlank(this.getProductName())){
            lqw.like(alias+"product_name",this.getProductName());
        }
        if (StringUtils.isNotBlank(this.getProductColor())){
        lqw.like(alias+"product_color" ,this.getProductColor());
        }
        if (StringUtils.isNotBlank(this.getNumberItems())){
        lqw.eq(alias+"number_items" ,this.getNumberItems());
        }
        if (this.getTotalSizeEmpty() != null){
        lqw.eq(alias+"total_size_empty" ,this.getTotalSizeEmpty());
        }
        if (this.getTotalSizeSufficient() != null){
        lqw.eq(alias+"total_size_sufficient" ,this.getTotalSizeSufficient());
        }
        if (this.getStandardCodeEmpty() != null){
        lqw.eq(alias+"standard_code_empty" ,this.getStandardCodeEmpty());
        }
        if (this.getStandardCodeSufficient() != null){
        lqw.eq(alias+"standard_code_sufficient" ,this.getStandardCodeSufficient());
        }
        if (this.getSamplingQuantity() != null){
        lqw.eq(alias+"sampling_quantity" ,this.getSamplingQuantity());
        }
        if (this.getDifferenceValue() != null){
        lqw.eq(alias+"difference_value" ,this.getDifferenceValue());
        }
        if (this.getWeight() != null){
        lqw.eq(alias+"weight" ,this.getWeight());
        }
        if (this.getMeasureOverallWidth() != null){
        lqw.eq(alias+"measure_overall_width" ,this.getMeasureOverallWidth());
        }
        if (this.getPracticalWidth() != null){
        lqw.eq(alias+"practical_width" ,this.getPracticalWidth());
        }
        if (this.getStandardWidth() != null){
        lqw.eq(alias+"standard_width" ,this.getStandardWidth());
        }
        if (StringUtils.isNotBlank(this.getFlockingDotSize())){
        lqw.eq(alias+"flocking_dot_size" ,this.getFlockingDotSize());
        }
        if (StringUtils.isNotBlank(this.getFlockedFurColorComparison())){
        lqw.eq(alias+"flocked_fur_color_comparison" ,this.getFlockedFurColorComparison());
        }
        if (StringUtils.isNotBlank(this.getColorComparison())){
        lqw.eq(alias+"color_comparison" ,this.getColorComparison());
        }
        if (StringUtils.isNotBlank(this.getKilograms())){
        lqw.eq(alias+"kilograms" ,this.getKilograms());
        }
        if (StringUtils.isNotBlank(this.getOrdinaryWaterWashing())){
        lqw.eq(alias+"ordinary_water_washing" ,this.getOrdinaryWaterWashing());
        }
        if (StringUtils.isNotBlank(this.getStrongWashingOne())){
        lqw.eq(alias+"strong_washing_one" ,this.getStrongWashingOne());
        }
        if (StringUtils.isNotBlank(this.getStrongWashingTwo())){
        lqw.eq(alias+"strong_washing_two" ,this.getStrongWashingTwo());
        }
        if (StringUtils.isNotBlank(this.getDryWipeEvaluation())){
        lqw.eq(alias+"dry_wipe_evaluation" ,this.getDryWipeEvaluation());
        }
        if (StringUtils.isNotBlank(this.getWetWipeEvaluation())){
        lqw.like(alias+"wet_wipe_evaluation" ,this.getWetWipeEvaluation());
        }
        if (StringUtils.isNotBlank(this.getTrackFlag())){
            lqw.eq(alias+"track_flag" ,this.getTrackFlag());
        }
        if (this.getDocumentaryId() != null){
        lqw.eq(alias+"documentary_id" ,this.getDocumentaryId());
        }
        if (StringUtils.isNotBlank(this.getDocumentaryMan())){
        lqw.eq(alias+"documentary_man" ,this.getDocumentaryMan());
        }
        if (this.getOperatorId() != null){
        lqw.eq(alias+"operator_id" ,this.getOperatorId());
        }
        if (StringUtils.isNotBlank(this.getOperatorName())){
        lqw.eq(alias+"operator_name" ,this.getOperatorName());
        }
        if (this.getOperatorTime() != null){
        lqw.eq(alias+"operator_time" ,this.getOperatorTime());
        }
        if (this.getSort() != null){
        lqw.eq(alias+"sort" ,this.getSort());
        }
        if (StringUtils.isNotBlank(this.getRemarks())){
        lqw.eq(alias+"remarks" ,this.getRemarks());
        }
        if (StringUtils.isNotBlank(this.getCreateBy())){
        lqw.eq(alias+"create_by" ,this.getCreateBy());
        }
        if (this.getCreateTime() != null){
        lqw.eq(alias+"create_time" ,this.getCreateTime());
        }
        if (StringUtils.isNotBlank(this.getUpdateBy())){
        lqw.eq(alias+"update_by" ,this.getUpdateBy());
        }
        if (this.getUpdateTime() != null){
        lqw.eq(alias+"update_time" ,this.getUpdateTime());
        }
        if (this.getDelStatus() != null){
        lqw.eq(alias+"del_status" ,this.getDelStatus());
        }
        if (StringUtils.isNotBlank(this.getSearchName())) {
            lqw.and(wrapper -> wrapper.like("gp.sn", this.getSearchName()).or().like("gp.product_name", this.getSearchName()).or().like("gp.product_color", this.getSearchName()));
        }
        if (this.getSearchDate() != null) {
            lqw.apply("DATE_FORMAT(gp.create_time, '%Y-%m-%d') = '" + DateUtils.dateTime(this.getSearchDate()) + "'");
        }
    }
}
